package tasoloikka;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

public class Tile {

  //Objektin sijainti & koko
  private int positionX;
  private int positionY;
  private int width;
  private int height;
  private String type;
  private String info;
  private boolean block;

  public Tile(int x, int y, int w, int h, String t, String i, boolean b) {
    this.positionX = x;
    this.positionY = y;
    this.width = w;
    this.height = h;
    this.block = b;
    this.info = i;
    this.type = t;
  }

  public void paint(Graphics gbi, int i, int j) {
    if (block) {
      gbi.setColor(Color.RED);
    } else {
      gbi.setColor(Color.magenta);
    }


    gbi.drawRect(i * 16, j * 16, width, height);
  }

  //Getterit
  public Rectangle getRectangle() {
    return (new Rectangle(positionX, positionY, width, height));
  }

  public int getPositionX() {
    return positionX;
  }

  public int getPositionY() {
    return positionY;
  }

  public int getWidth() {
    return width;
  }

  public int getHeight() {
    return height;
  }

  public boolean getBlock() {
    return block;
  }

  public String getSaveInfo() {
    int blockInfo;
    if (block) {
      blockInfo = 1;
    } else {
      blockInfo = 0;
    }

    return (0 + "|" + 0 + "|" + width + "|" + height + "|" + type + "|" + info + "|" + blockInfo);
  }
}
